#include "time_aspect.h"
#include "aspect_manage.h"
#include <chrono>
#include <thread>

class Node
{
public:
    void Create(int a) { LOG_INFO("a  = %d", a); }
};
int main()
{
    int a = 2;
    auto func111 = []() {
        int a = 1, b = 2;
        std::this_thread::sleep_for(std::chrono::milliseconds(100));
        LOG_INFO("a + b = %d", a + b);
    };

    auto Add = [](int a, int b) -> int {
        std::this_thread::sleep_for(std::chrono::milliseconds(100));
        LOG_INFO("a + b = %d", a + b);
        return a + b;
    };
    Node node;
    int ret = 0;
    AspectAssembly<TimeCal>("Node", "Create",
                            [&node, &a]() { node.Create(a); });
    AspectAssembly<FunctionExecCnt, TimeCal>([&] { node.Create(a); });
    AspectAssembly<FunctionExecCnt, TimeCal>("main", "Add",
                                             [&]() { ret = Add(1, 2); });
    LOG_INFO("add result: %d", ret);

    return 0;
}
